package com.foreknow.elmboot.controller;

import com.foreknow.elmboot.mapper.UserMapper;
import com.foreknow.elmboot.po.User;
import com.foreknow.elmboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/UserController")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 根据用户编号与密码查询用户信息
     * @param user
     * @return
     * @throws Exception
     */
    @RequestMapping("/getUserByIdByPass")
    public User getUserByIdByPass(User user) {
        return userService.getUserByIdByPassService(user.getUserId(),user.getPassword());
    }

    /**
     * 根据用户编号查询用户表返回的行数
     * @param userId
     * @return
     * @throws Exception
     */
    @RequestMapping("/getUserById")
    public int getUserById (String userId) {
        return userService.getUserByIdService(userId);
    }

    /**
     * 向用户表中添加一条记录
     * @param user
     * @return
     * @throws Exception
     */
    @RequestMapping("/saveUser")
    public int saveUser(User user){
        return userService.saveUserService(user);
    }
}
